home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!craigl
- From: craigl@teleport.com (Craig Lovegren)
- Newsgroups: comp.lang.c,comp.lang.c++,alt.msdos.programmer
- Subject: Re: Clearing the keyboard buffer
- Followup-To: comp.lang.c,comp.lang.c++,alt.msdos.programmer
- Date: 26 Jan 1996 05:19:31 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4e9o93$9g0@maureen.teleport.com>
- References: <4dtqi4$60u@cdc2.cdc.net> <4e07uh$oqq@huron.eel.ufl.edu>
- NNTP-Posting-Host: linda.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Daniel P Hudson (afn03257@freenet2.freenet.ufl.edu) wrote:
- : In article <4dtqi4$60u@cdc2.cdc.net>,
- : mart@vianet.on.ca (Mart) wrote:
-
- : > I'm using Turbo C++ v. 3.1 and I need to be able to clear the keyboard
- : > BTW, this following bit of code wouldn't work :
-
- : > while(kbhit()) getch();
-
- : > Because I want the user to be able to just keep pushing the same key,
- : > making the above loop infinitly. If I don't clear the keyboard buffer,
- : > my code will continue believing that the user is pushing a key, even
- : > though their not.
-
- : Huh? Once the buffer is caught up, it shouldn't continue, but you
- : might want to try fflush(stdin); just the same. The code you had
- : should work as soon as it has read through all the keystrokes currently
- : stored, the only way it should have a situation like you describe is if
- : the user presses a key after it has executed, in which case your only
- : prevention would be to disable the keyboard.
-
- Well... what about typematic delays? If, while you are in DOS, you press
- and hold a key... it will first appear... then wait... then continue to
- fill up the line with that character. In this instance the line will
- execute and process the first character... then the typematic delay
- hits... the line will then finish since no more keys have been hit (still
- in the delay) once the delay is over however it will continue to fill the
- buffer up once again. At least that is how I understand it.
-
- --
- Real Life: Craig R. Lovegren
- CyberLife: craigl@teleport.com
- IRC Life: Son-Of-Yo
-